home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_100 / 104_01 / c.def < prev    next >
Text File  |  1980-01-01  |  6KB  |  192 lines

  1. /*********************************************************************/
  2. /*                                                                   */
  3. /*   This C compiler is copied from Dr. Dobb's Journal of Computer   */
  4. /*        Calisthenics & Orthodontia (issue number 45)               */
  5. /*   -- Distribution and use is unrestricted for non-commercial use. */
  6. /*                                                                   */
  7. /*                                                 RAF 8-8-80        */
  8. /*                                                                   */
  9. /*********************************************************************/
  10.  
  11. /************************************************/
  12. /*                                              */
  13. /*             small-c compiler                 */
  14. /*                 rev. 1.1                     */
  15. /*               by Ron Cain                    */
  16. /*                                              */
  17. /************************************************/
  18.  
  19. /*      Define system dependent parameters      */
  20.  
  21. /*      Stand-alone definitions                 */
  22.  
  23. #define BUFSIZ    1030
  24. #define ERROR    -1
  25. #define FALSE    0
  26. #define TRUE    1
  27. #define eol     13    
  28. #define CR    13    
  29. #define LF    10
  30. #define BS    8
  31. #define TB    9
  32. #define FF    12
  33.  
  34. /*      Define symbol table parameters          */
  35. #define lvalsize 3
  36. #define SWITCH_MAX 254
  37. #define symsiz  15
  38. #define symtbsz 6000
  39. #define numglbs 300
  40. #define startglb symtab
  41. #define endglb  startglb+numglbs*symsiz
  42. #define startloc endglb+symsiz
  43. #define endloc  symtab+symtbsz-symsiz
  44.  
  45. /*      Define symbol table entry format        */
  46.  
  47. #define name    0
  48. #define ident   9
  49. #define type    10
  50. #define indcnt    11
  51. #define storage 12
  52. #define offset  13
  53. #define offset1    14
  54. /*      System wide name size (for symbols)     */
  55.  
  56. #define namesize 9
  57. #define namemax  8
  58.  
  59. /*      Define possible entries for "ident"     */
  60.  
  61. #define variable    1        /* a normal varble */
  62. #define array        2        /* array of varbles */
  63. #define pointer        3        /* pointer to a varble */
  64. #define function    4        /* entry is a function */
  65. /*      Define possible entries for "type"      */
  66.  
  67. #define cchar   1
  68. #define cint    2
  69.  
  70. /*    Lenght of possible entries for "type"    */
  71.  
  72. #define lchar    1
  73. #define lint    2
  74. #define lpoint    2
  75.  
  76. /*      Define possible entries for "storage"   */
  77.  
  78. #define statik  1
  79. #define stkloc  2
  80. #define stkarg  3
  81.  
  82. /*    values returned by heirxx         */
  83.  
  84. #define    LOADED        0    /* value on top of stack */
  85. #define ADDRESS        1    /* address of lvalue on stack */
  86. #define NOTLOADED    2    /* address in lvalue in array not loaded */
  87. #define CONSTANT    3    /* constant in lval */
  88. /*      Define the "while" statement queue      */
  89.  
  90. #define wqtabsz 100
  91. #define wqsiz   6
  92. #define wqmax   wq+wqtabsz-wqsiz
  93.  
  94. /*      Define entry offsets in while queue     */
  95.  
  96. #define wqsym   0
  97. #define wqsp    1
  98. #define wqloop  2
  99. #define wqlab   3
  100. #define wqend    4
  101. #define wqbody    5
  102. /*      Define the literal pool                 */
  103.  
  104. #define litabsz 2000
  105. #define litmax  litabsz-1
  106.  
  107. /*      Define the input line                   */
  108.  
  109. #define linesize 80
  110. #define linemax linesize-1
  111. #define mpmax   linemax
  112.  
  113. /*      Define the macro (define) pool          */
  114.  
  115. #define macqsize 1000
  116. #define macmax  macqsize-1
  117.  
  118. /*      Define statement types (tokens)         */
  119.  
  120. #define stif    1
  121. #define stwhile 2
  122. #define stfor    3
  123. #define stswitch 4
  124. #define streturn 5
  125. #define stbreak 6
  126. #define stcont  7
  127. #define stasm   8
  128. #define stexp   9
  129.  
  130. /*    name of some function called by code gen step */
  131.  
  132. #define EQ    "@comp"        
  133. #define    GE    "@comp+25h"    
  134. #define GT    "@comp+12h"    
  135. #define LE    "@comp+2fh"
  136. #define LT    "@comp+1ch"
  137. #define NE    "@comp+19h"
  138.  
  139. #define UGE    "@ucomp+13h"
  140. #define UGT    "@ucomp"
  141. #define    ULE    "@ucomp+1ch"
  142. #define    ULT    "@ucomp+0ah"
  143.  
  144. #define PREINC    "@incdec"
  145. #define PREDEC    "@incdec+08h"
  146. #define POSTINC    "@incdec+10h"
  147. #define POSTDEC    "@indec+1ah"
  148.  
  149. /*      Now reserve some storage words          */
  150.  
  151. char    symtab[symtbsz];        /* symbol table */
  152. char    *glbptr,*locptr;                /* ptrs to next entries */
  153. int     wq[wqtabsz];            /* while queue */
  154. int     *wqptr;                 /* ptr to next entry */
  155.  
  156. char    litq[litabsz];          /* literal pool */
  157. int     litptr;                 /* ptr to next entry */
  158.  
  159. char    macq[macqsize];         /* macro string buffer */
  160. int     macptr;                 /* and its index */
  161.  
  162. char    line[linesize];         /* parsing buffer */
  163. char    mline[linesize];        /* temp macro buffer */
  164. int     lptr,mptr;              /* ptrs into each */
  165.  
  166. /*      Misc storage    */
  167.  
  168. int     nxtlab,         /* next avail label # */
  169.         litlab,         /* label # assigned to literal pool */
  170.         sp,             /* compiler relative stk ptr */
  171.         argstk,         /* function arg sp */
  172.         ncmp,           /* # open compound statements */
  173.         errcnt,         /* # errors in compilation */
  174.         eof,            /* set non-zero on final input eof */
  175.         input,          /* iob # for input file */
  176.         output,         /* iob # for output file (if any) */
  177.         input2,         /* iob # for "include" title */
  178.     line1,        /* current line number in main file */
  179.     line2,        /* current line in include file */
  180.         ctext,          /* non-zero to intermix c-source */
  181.         cmode,          /* non-zero while parsing c-code */
  182.                         /* zero when passing assembly code */
  183.     cif,        /* state of preprocess if statement */
  184.         lastst;         /* last executed statment type */
  185.  
  186. char    *cptr;          /* work ptr to any char buffer */
  187. int     *iptr;          /* work ptr to any int buffer */
  188. /*    file io buffers        */
  189. char finp[BUFSIZ];        /* input file buffer */
  190. char finp2[BUFSIZ];        /* input 2 file buffer */
  191. char fout[BUFSIZ];        /* ouput file buffer */
  192. n&σ═    3╤!    ^#Vr+s├^3*₧═∙═⌐╥─3*₧═?═·δ═╦├╟3!δ!    s#r!    ^#Vr+sz│╩≡3!µ3├Φ3    σ═3╤├╧3├4!∙3├²3            σ═